#include <boost/asio.hpp>
#include <iostream>
#include <boost/array.hpp>
#include <string>

int main() {
    try {
        boost::asio::io_context io_context;
        boost::asio::ip::udp::resolver resolver(io_context);
        boost::asio::ip::udp::resolver::results_type endpoints = resolver.resolve("127.0.0.1", "12345");

        boost::asio::ip::udp::socket socket(io_context);
        std::string message = "Hello from client!";
        boost::asio::ip::udp::endpoint receiver_endpoint = *endpoints.begin();

        socket.send_to(boost::asio::buffer(message), receiver_endpoint);

        // Optional: Receive a response from the server
        boost::array<char, 1024> recv_buf;
        size_t len = socket.receive_from(boost::asio::buffer(recv_buf), receiver_endpoint);
        std::cout << "Received: " << std::string(recv_buf.data(), len) << std::endl;
    } catch (std::exception& e) {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}